package yygh.oss.Controller;


import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import yygh.common.result.Result;
import yygh.oss.Servcie.FileService;

@RestController
@RequestMapping("/api/oss")
public class FileApiController {


    @Autowired
    FileService fileService;

    //方法接口1：实现文件的上传至阿里云oss
    @ApiOperation("实现文件的上传至阿里云oss")
    @PostMapping("/fileUpload")
    public Result upload(MultipartFile file){
       //调用service层的upload方法，返回一个路径
        String url= fileService.upload(file);
        return Result.ok(url);
    }

}
